<template>
  <el-container class="bg-white rounded" :style="{ height: h + 'px' }">
    <el-header class="image-header">
      <el-button type="primary" size="small" @click="handleOpenCreate"
        >新增分類</el-button
      >
      <el-button type="warning" size="small" @click="handleOpenUpload"
        >上傳圖片</el-button
      >
    </el-header>
    <el-container>
      <ImageAside ref="imageAsideRef" @change="handleAsideChange" />
      <ImageMain ref="ImageMainRef" />
    </el-container>
  </el-container>
</template>

<script setup>
import { ref } from "vue";
import ImageAside from "~/components/ImageAside.vue";
import ImageMain from "~/components/ImageMain.vue";
const windowHeight = window.innerHeight || document.body.clientHeight;
const h = windowHeight - 64 - 44 - 40;

const imageAsideRef = ref(null);
const ImageMainRef = ref(null);
const handleOpenCreate = () => {
  imageAsideRef.value.handleCreate();
};

const handleAsideChange = (id) => {
  return ImageMainRef.value.loadData(id);
};
//上传图片
const handleOpenUpload = () => ImageMainRef.value.openUploadFile();
</script>

<style>
.image-header {
  border-bottom: 1px solid #eee;
  @apply flex items-center;
}
</style>
